<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />

<div class="container" id="fund">
	<div class="tabs-left">
		<ul class="nav nav-tabs nav-stacked" id="fund-tab">
			<li class="active"><a href="#order-management"><span class="hidden-phone">购买列表</span><span class="visible-phone">已买</span></a></li>
			<li id="fund_detail"><a href="#fund-detail"><span class="hidden-phone">收支明细</span><span class="visible-phone">收支</span></a></li>
			<li><a href="#alipay" ><span class="hidden-phone">账户充值</span><span class="visible-phone">充值</span></a></li>
			<li><a href="#getcash" >提现</a></li>
		</ul>
	</div>
	<div class="tab-content in_out_manage">
		<!-- 资助管理 -->
		<div class="tab-pane active" id="order-management" style="min-height:500px;"></div>
		<!-- 收支明细 -->
		<div class="tab-pane" id="fund-detail" style="min-height:500px;">
			<div class="table-title" style="height: 30px;">
				<div class="select-style hidden-phone">
					<select id="days">
						<option id="" value="15" selected>最近半个月</option>
						<option id="" value="30">最近一个月</option>
						<option id="" value="60">最近两个月</option>
						<option id="" value="150">最近半年</option>
						<option id="" value="730">两年内</option>
					</select>
				</div>
				<div class="fund-title" id="fund-title"></div>
			</div>
			<div class="row-fluid" id="fund-table"></div>
		</div>
		<!-- 账户充值 -->
		<div class="tab-pane" id="alipay">

			<form id="deposit" >
				<input type="hidden" name="user.id" value= "<shiro:principal property="id"/>" />
				<div class="zfb">	</div>
				<div class="balance">
					<h4>账户余额</h4>
					<span id="userBalance0"></span><span>元</span>
				</div>
				<p style="font-size:16px;">亲爱的<span
					class="suppliment_user" id="suppliment_user"></span>，您可以使用支付宝充值，请填写以下信息：
				</p> 
				<div>
					<label class="radio inline">充值金额
						<input class="compliment_count visi-fund" name="amount" id="custom">元
					</label>
				</div>
				<p class="warm_prompt">温馨提示:<br />1.采用支付宝充值，1元可以充值1元。<br />2.若出现已充值成功的提示，但YAMI账户未到账，可能是网络或者系统繁忙导致，我们会在2个工作日内核对后为您充值<br />3在充值过程中如出现网页错误或打开缓慢时，请先查询支付宝的交易记录，检查扣款是否成功；然后查看YAMI账户是否成功充值。若没有确认，请不要反复刷新页面，以防止重复购买。
				</p>
				
				<td></td>
				<td><button class="affirm-donate" id="rechange">立即充值</button></td>
				
			</form>
		</div>
		<!-- 提现 -->
		<div class="tab-pane" id="getcash">

			<form id="getcash-form" >
				<input type="hidden" name="uid" value= "<shiro:principal property="id"/>" />
				<input type="hidden" name="payType" value="0" class="pay-type">
				<div class="zfb">	</div>
				<div class="balance">
					<h4>账户余额</h4>
					<span id="userBalance2"></span><span>元</span>
				</div>
				<p style="font-size:16px;">亲爱的<span
					class="suppliment_user" id="suppliment_user"></span>，您可以提现到支付宝或银行卡，请填写以下信息：
				</p> 
				<div class="form-group">
			             <label for="real-name" class="col-sm-2">真实姓名</label>
			             <div class="col-sm-10">
			             <input type="text" name="realName" class="form-control rel-name visi-getcash">
			             </div>
			             <label for="phone" class="col-sm-2">电话</label>
			             <div class="col-sm-10">
			             <input type="text" name="phone" class="form-control rel-phone visi-getcash">
			             </div>
			             <label for="number" class="col-sm-2"><input type="radio" checked="checked" value="0" name="cashtype"  class="cash-type">支付宝账号
			             &nbsp;&nbsp;<input type="radio" class="cash-type cash-bank" value="1" name="cashtype">银行卡号</label>
			             <div class="col-sm-10">
			             <input type="text" name="account" class="form-control input-type rel-pay visi-getcash" placeholder="请输入支付宝账号">
			             </div>
			             <label for="amout" class="col-sm-2 bank-name" style="display:none;">银行名称</label>
			             <div class="col-sm-10 bank-input" style="display:none;">
			             <input type="text" name="bank" class="form-control rel-bank visi-getcash">
			             </div>
			             <label for="amout" class="col-sm-2">提现金额</label>
			             <div class="col-sm-10">
			             <input type="text" name="amount" class="form-control visi-getcash">
			             </div>
				</div>
				<p class="warm_prompt">温馨提示:<br />1.<br />2.<br />3.
				</p>
				
				<td></td>
				<td><button class="affirm-donate" type="button" id="getcash-button">立即提现</button></td>
				
			</form>
		</div>
	</div>
</div>


<div id="confirm-order" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h3 id="myModalLabel">
			确认订单
		</h3>
	</div>
	<div class="modal-body">
		亲爱的<span class="suppliment_user" id="suppliment_user"><shiro:principal property="name"/></span>：<br/>
		当前余额：<span class="balance" id="userfund"></span><br/>

		<form id="deposit" action="https://mapi.alipay.com/gateway.do?_input_charset=utf-8" name= "alipaysubmit" method="post" target="_blank">
			本次充值：<input class="balance" id="total_fee" readonly="readonly"><br/>
			<input type="hidden" name="payment_type" id="payment_type" value="">
			<input type="hidden" name="notify_url" id="notify_url" value="">
			<input type="hidden" name="return_url" id="return_url" value="">
			<input type="hidden" name="service" id="service" value="">
			<input type="hidden" name="partner" id="partner" value="">
			<!-- <input type="hidden" name="key" id="key" value=""> -->
			<input type="hidden" name="sign_type" id="sign_type" value="MD5">
			<input type="hidden" name="sign" id="key" value="">
			<!-- <input type="hidden" name="_input_charset" id="_input_charset" value=""> -->
			<input type="hidden" name="seller_id" id="seller_id" value="">
			<input type="hidden" name="out_trade_no" id="out_trade_no" value="">
			<input type="hidden" name="subject" id="subject" value="">
			<button class="affirm-donate" id="rechange">确认充值</button>
		</form>

	</div>
</div>
<script type = "text/html" id="alipay-template">

</script>
<!-- 资助管理 -->
<script type="text/html" id="order-management-template">
<table class="table">
<thead>
<tr class="home_jsb_title">
<th class=""><span class="hidden-phone">服务名称</span><span class="visible-phone">名称</span></th>
<th class="hidden-phone">订单号</th>
<th class="">状态</th>
<th class=""><span class="hidden-phone">金额（元）</span><span class="visible-phone">金额</span></th>
<th class="hidden-phone">成交时间</th>
</tr>
</thead>
<tbody >

<$for(var i = 0;i<result.length;i++){$>
	<tr>
	<td class="column1">
	<div class="media">
	<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="pull-left"><img
	class="media-object img-polaroid hidden-phone" alt="70*70"
	src="<$=result[i].project.photoUrl$>" title="<$=result[i].project.name$>"></a>
	<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="project media-align-middle"><$=result[i].project.name$></a>
	</div>
	</td>
	<td class="textcenter hidden-phone"><$=result[i].fundCode$></td>
	<td class="textcenter">
<$if(result[i].status == 101){$>
<li class="projectFundStatus">购买成功</li>
<li>正在发送回报</li></td>
<$}else if(result[i].status == 102){$>
<li class="projectFundStatus">购买成功</li>
<li>已发送回报</li></td>
<$}else if(result[i].status == 201){$>
<li class="projectFundStatus">购买失败</li>
<li>正在退款</li></td>
<$}else if(result[i].status == 202){$>
<li class="projectFundStatus">购买失败</li>
<li>已退款</li></td>
<$}else{$>
<li class="projectFundStatus">获取状态失败</li>
<li>请与客服联系</li></td>
<$}$>

<td class="textcenter"><$=result[i].productPrice*result[i].productAmount$></td>
<td class="textcenter hidden-phone">
<li><$=result[i].createdDate$></li></td>
</tr>
<$}$>
</tbody>
</table>
<$ if ( totalPages > 1 ) { $>
<div class="pagination">
<$==pagination$>
</div>
<$}$>
</script>

<!-- 收支明细 -->
<script type="text/html" id="fund-title-template">
	<div class="fund-margin">
		收入：<span style="color:green;" class="income balance"><$=abundant$></span>元
	</div>
	<div class="fund-margin">
		支出：<span style="color:red;" class="outcome balance"><$=consume$></span>元
	</div>
	<div class="fund-margin">
		余额：<span style="font-size:20px;" id="userBalance1"></span>元
	</div>
</script>
<script type="text/html" id="fund-table-template">
<table class="table visi-table">
	<thead>
		<tr class="home_jsb_title">
			<th style="text-align:center;" class="hidden-phone">时间</th>
			<th class="jsb_detail" style="padding-left: 60px;">详情</th>
			<th class="jsb_pay" style="min-width:30px;">收支</th>
			<th class="jsb_pay" style="text-align: center;min-width:30px;"><span class="hidden-phone">金额（元）</span><span class="visible-phone">金额</span></th>
		</tr>
	</thead>
	<tbody id="fund-detail-tbody">
	<$for(var i = 0;i<page.result.length;i++){$>
		<tr class="fund-detail">
			<td style="text-align: center;" class="hidden-phone"><$=page.result[i].createdDate$></td>		
		<$switch (page.result[i].actionType){
			case 0:$>	
				<td>支持<a class="brown" href="${ctx}/project/detail?id=<$=page.result[i].project.id$>"><b><$="<<"$><$=page.result[i].project.name$><$=">>"$></b></a></td>
				<td style="color:red;">支出</td>
				<$break;
			case 1:$>
				<td>支付宝充值</td>
				<td class="brown" style="color:green;">收入</td>
				<$break;
			case 2:$>
				<td>使用优惠券</td>
				<td class="brown" style="color:green;">收入</td>
				<$break;
			case 3:$>	
				<td>充值未生效订单</td>
				<td style="color:gray;">收入</td>
				<$break;
			case 4:$>	
				<td>服务<b><$="<"$><$=page.result[i].product.name$><$=">"$></b></td>
				<td style="color:green;">收入</td>
				<$break;
			case 5:$>
				<td>提现申请中</td>	
				<td style="color:gray;">支出</td>
				<$break;
			case 6:$>	
				<td>提现</td>
				<td style="color:red;">支出</td>
				<$break;
			}$>
				<td class="fundInfor" style="text-align: center;"><$=page.result[i].amount$></td>
		</tr>
	<$}$>
	</tbody>
</table>
<$ if ( page.totalPages > 1 ) { $>
<div class="pagination">
<$==page.pagination$>
</div>
<$}$>
</script>
<c:if test="${env == 'production' }">
<script type="text/javascript">
seajs.use("${ctx}/assets/js-dist/home/fund-page");
</script>
</c:if>
<c:if test="${env != 'production' }">
<script type="text/javascript">
seajs.use("${ctx}/assets/js/home/fund-page");
</script>
</c:if>
